#pragma once

#include "Framework.h"

namespace Framework
{
	class _HELIX_FRAMEWORK_ITEM Vector2
	{
	public:
		Vector2() : x(0), y(0) {}
		Vector2(float x, float y);
		friend Vector2 operator + (Vector2& a, Vector2& b) { return Vector2(a.x+b.x, a.y+b.y); }
		friend Vector2 operator - (Vector2& a, Vector2& b) { return Vector2(a.x-b.x, a.y-b.y); }
		friend Vector2 operator * (Vector2& a, const float f) { return Vector2(a.x*f, a.y*f); }
		friend Vector2 operator * (const float f, Vector2& a) { return Vector2(a.x*f, a.y*f); }
		friend Vector2 operator * (Vector2& a, Vector2& b) { return Vector2(a.x*b.x, a.y*b.y); }
		friend Vector2 operator / (Vector2& a, const float f) { return Vector2(a.x/f, a.y/f); }
		friend Vector2 operator / (Vector2& a, Vector2& b) { return Vector2(a.x/b.x, a.y/b.y); }
		Vector2 operator - () { return Vector2(-x, -y); }
		static float Dot(Vector2& a, Vector2& b);
		static float SqrLength(Vector2& vector);
		static float Length(Vector2& vector);
		static Vector2 GetNormal(Vector2& vector);
		static Vector2 BaryCentric(Vector2& a, Vector2& b, Vector2& c, float b1, float b2);
		static Vector2 Null;
		static Vector2 UnitX;
		static Vector2 UnitY;
		union
		{
			struct { float x, y; };
			struct { float cell[2];};
		};
	};

	inline Vector2 Vector2::BaryCentric(Vector2& a, Vector2& b, Vector2& c, float b1, float b2)
	{
		Vector2 out;
		out = (a + ((b - a) * b1)) + ((c - a) * b2);
		return out;
	}
};